import { PSControlObjectImpl } from '../pscontrol-object-impl';
import { IPSDEChartTitle } from './ipsdechart-title';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEChartTitleImpl extends PSControlObjectImpl implements IPSDEChartTitle {
  get index(): number {
    return this.M.index;
  }

  get subTitle(): string {
    return this.M.subTitle;
  }

  protected subtitlepslanguageres: IPSLanguageRes | null = null;

  getSubTitlePSLanguageRes(): IPSLanguageRes | null {
    if (this.subtitlepslanguageres != null) return this.subtitlepslanguageres;
    const value = this.M.getSubTitlePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.subtitlepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getSubTitlePSLanguageRes') as IPSLanguageRes;
    return this.subtitlepslanguageres;
  }

  get subTitlePSLanguageRes(): IPSLanguageRes | null {
    return this.getSubTitlePSLanguageRes();
  }

  getSubTitlePSLanguageResMust(): IPSLanguageRes {
    const value = this.getSubTitlePSLanguageRes();
    if (value == null) {
      throw new Error('未指定子标题语言资源');
    }
    return value;
  }

  get title(): string {
    return this.M.title;
  }

  protected titlepslanguageres: IPSLanguageRes | null = null;

  getTitlePSLanguageRes(): IPSLanguageRes | null {
    if (this.titlepslanguageres != null) return this.titlepslanguageres;
    const value = this.M.getTitlePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.titlepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getTitlePSLanguageRes') as IPSLanguageRes;
    return this.titlepslanguageres;
  }

  get titlePSLanguageRes(): IPSLanguageRes | null {
    return this.getTitlePSLanguageRes();
  }

  getTitlePSLanguageResMust(): IPSLanguageRes {
    const value = this.getTitlePSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源');
    }
    return value;
  }

  get titlePos(): string {
    return this.M.titlePos;
  }

  get showTitle(): boolean {
    return this.M.showTitle;
  }

  get cls(): string {
    return 'PSDEChartTitleImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.chart.IPSChartTitle' || cls == 'control.chart.IPSDEChartTitle') return true;
    return super.instanceof(cls);
  }
}
